<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后勤管理-采购清单</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/houqin_assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/houqin_assets/css/style.css" rel="stylesheet">
	<link href="/houqin_assets/css/font-awesome.css" rel="stylesheet">
</head>

<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 后勤管理</span><b class="fa fa-caret-right"></b><i>采购清单</i></div>
			</div>
			<div  class="mes-conttent col-xs-12">
				<table class="table off-table">
	              <thead>
	             	<tr>
			        <th>编号</th>
			        <th>申请物品</th>
			        <th>申请数量</th>
			        <th>申请时间</th>
			        <th>是否购买</th>
		            </tr>
	              </thead>
	             <tbody>
                    <?foreach($tDatas as $tRow){?>
                    <tr>
                        <td name="id"><?=$tRow['id']?></td>
                        <input type="hidden" name="aid" value="<?=$tRow['a_id']?>"/>
                        <td><?=$tRow['apply_name']?></td>
                        <td><?=$tRow['apply_num']?><?=$tRow['apply_com']?></td>
                        <td name="basic_fee"><?=empty($tRow['apply_time'])?'':date('Y-m-d',$tRow['apply_time'])?></td>
                        <td><?if($tRow['status'] == '1'){?><button type="button" class="issueBtn">确认购买</button><?}else{?>已购买<?}?></td>
                    </tr>
                    <?}?>
	            </tbody>
              </table>
            <?=$tShow?>
			</div>
		</div>
    </div>
        <script type="text/javascript" src="/houqin_assets/js/jquery.min.js"></script>
<script>
$('#search').click(function(){
    $('form').submit();
});
/*获取地址栏参数*/
function GetQuery(key){
	var search = location.search.slice(1);//得到get方式提交的查询字符串
	var arr = search.split("&");
	for(var i = 0; i < arr.length; i++){
		var ar = arr[i].split("=");
		if(ar[0] == key){
			return ar[1];
		}
	}
}
    var color="#eeeeee";
    $("#table_list tr:odd td").css("background-color",color);  //改变偶数行背景色
    /* 把背景色保存到属性中 */
    $("#table_list tr:odd").attr("bg",color);

    $('.issueBtn').each(function(){
        $(this).on('click',function(){
            var id = $(this).parent().parent().find('td[name="id"]').text();
            var aid = $(this).parent().parent().find('input[name="aid"]').val();
            $.post('/admin_purchases',{ id:id,aid:aid },function(obj){
                if(obj.status == 0){
                    alert(obj.msg);return;
                }else{
                    alert(obj.msg);location.href="/admin_purchases";
                }
            });
        });    
    });
</script>
</body>
</html>
